package com.example.modularweb.web;


import com.example.modularcommon.ApiResponse;
import com.example.modularcommon.ResponseEnum;
import com.example.modularpersistent.domain.User;
import com.example.modularservice.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping("getUser")
    public ApiResponse<User> getUser(@RequestParam("id") int id) {
        User user = userService.getUser(id);
        ApiResponse<User> userApiResponse = new ApiResponse<>();
        userApiResponse.setCode(ResponseEnum.SUCCESS.getCode());
        userApiResponse.setMessage(ResponseEnum.SUCCESS.getMessage());
        userApiResponse.setData(user);
        return userApiResponse;
    }

}
